package com.his.controller;

import com.alibaba.fastjson.JSONArray;
import com.his.bean.DzmHisDoctor;
import com.his.bean.DzmHisScheduling;
import com.his.service.DzmHisSchedulingService;
import com.his.utils.ResponseResult;
import jdk.nashorn.internal.runtime.Undefined;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/Scheduling")
public class DzmHisSchedulingController {
    @Autowired
    DzmHisSchedulingService dzmHisSchedulingService;

    /**
     * 查询排班(多表）
     *
     * @param dzmHisScheduling
     * @return
     */
    @GetMapping("/getList")
    public ResponseResult getList(DzmHisScheduling dzmHisScheduling) {
        List<DzmHisScheduling> list = dzmHisSchedulingService.getList(dzmHisScheduling);
        return new ResponseResult(200, "查询排班成功", list);
    }

    /**
     * 查询医生新增排班弹窗信息
     *
     * @param dzmHisScheduling
     * @return
     */
    @GetMapping("/getRuleDoc")
    public ResponseResult getRuleDoc(DzmHisScheduling dzmHisScheduling) {
        List<DzmHisDoctor> list = dzmHisSchedulingService.getRoleDoc(dzmHisScheduling);
        System.out.println(list + "这是排班添加数据");
        return new ResponseResult(200, "查询医生新增排班弹窗信息ok", list);
    }

    @RequestMapping("/editSchedul")
    public ResponseResult editSchedul(@RequestBody List<Map<String,String>> data) {

        System.out.println(data + "=========>");
        HashMap<String,Object> map=new HashMap<>();

        List<Map<String,Object>> arrayList = new ArrayList<Map<String,Object>>();

        for(int i=0;i<data.size();i++){
            ArrayList<String> list=new ArrayList<>();
            map=new HashMap<>();
            map.clear();
            list.clear();
            map.put("id",data.get(i).get("id"));

            System.out.println(data.get(i).get("id")+"id");
            System.out.println(data.get(i).get("X10"));
            list.add(data.get(i).get("X10"));
            list.add(data.get(i).get("X21"));
            map.put("weeks",list);
//            map.put("week",data.get(i).get("X10"));
            System.out.println(map+"map");

            arrayList.add(map);



        }
        System.out.println(arrayList+"arraylist");
        System.out.println(arrayList.get(1).get("weeks")+"weeksxx ");
//        for(int i=0;i<)
        arrayList.get(1).get("weeks");

        return new ResponseResult(200, "看看数据", data);
    }

}
